package com.chukun.netty.zerocopy;

import java.io.DataInputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author chukun
 * 传统的IO服务端操作
 */
public class TraditionalIOServer {

    public static void main(String[] args) throws IOException {

        ServerSocket serverSocket = new ServerSocket(8899);
        Socket socket = serverSocket.accept();
        DataInputStream inputStream = new DataInputStream(socket.getInputStream());
        byte[] buffer = new byte[4096];
        long readCount=0;
        long markReadCount=0;
        while((markReadCount=inputStream.read(buffer))!=-1){
            readCount += markReadCount;
        }
        System.out.println("服务器端收到数据: "+readCount);
        inputStream.close();
    }
}
